<template>
	<view class="main">
		<!-- tabs -satrt -->
		<view class="tabs">
			<view class="tabs-item" :class="[queryParams.status ==0?'tabs-item-active':'']" @click="switchTabs(0)">
				<span class="tabs-item-text">待审核</span>
			</view>
			<view class="tabs-line"></view>
			<view class="tabs-item" :class="[queryParams.status ==1?'tabs-item-active':'']" @click="switchTabs(1)">
				<span class="tabs-item-text">已审核</span>
			</view>
		</view>
		<!-- tabs -end -->
		
		<view style="padding: 28upx 40upx;">
			<topSelectNew @onSearch="onSearch"></topSelectNew>
		</view>
		
		<!--list-satrt -->
		<view class="list">
			<view class="item" v-for="item in dataList">

				<view class="item-right">
					<view class="item-name">
						<view class="item-name-left">
							<u-icon name="account-fill" color="#88D7B3" size="20"></u-icon>
							<span class="item-name-tip">申请人</span>
							<span >{{item.userName}}</span>
						</view>

						<view v-if="queryParams.status ==0" class="item-btn" @click="toDetail(item.id)">审核</view>
						<view v-if="queryParams.status ==1" class="item-btn item-btn-gray">已审核</view>
					</view>
					<view class="item-single">
						<span class="item-single-name">名称</span>
						<span class="item-single-value">{{item.name}}</span>
					</view>
					<view class="item-single">
						<span class="item-single-name">价格</span>
						<span class="item-single-value">{{item.price}}</span>
					</view>
					<view class="item-single">
						<span class="item-single-name">申请时间</span>
						<span class="item-single-value" v-if="item.createTime">{{item.createTime.substring(0,10)}}</span>
					</view>

				</view>

			</view>
		</view>
		<!--list-end -->


		<view class="list-end" v-if="dataList.length">{{endText}}</view>

		<u-empty v-if="!dataList.length" mode="car" text="暂无数据" icon="/static/empty-img.png">
		</u-empty>

	</view>
</template>

<script>
	import topSelectNew from './topSelect.vue'
	export default {
		components: {
			topSelectNew
		},
		data() {
			return {
	
				queryParams: {
					status: '0',
					pageNum: 1,
					pageSize: 10
				},
				total: 0,
				endText: '',
				dataList: []
	
			}
		},
		onLoad() {
	
		},
		onShow() {
			this.queryParams.pageNum = 1
			this.dataList = []
			this.getList()
		},
		methods: {
	
			onSearch(param) {
				this.queryParams.pageNum = 1
				this.dataList = []
				this.queryParams = {
					...this.queryParams,
					...param
				}
				this.getList()
			},
			
	
			getList() {
				this.$modal.msgLoading('加载中')
	
				var that = this
	
				this.$postjson('/api/RqCompleteSh/list', this.queryParams).then(res => {
					uni.hideLoading()
					if (res.data.code == 200) {
						let detail = res.data.rows
						detail.forEach(v => {
							let img = v.imges ? v.imges.split(',') : []
							if (img.length) {
								v.cover = that.baseUrl + img[0]
							}
						})
	
	
						if (detail.length < that.queryParams.pageSize) {
							that.endText = '没有更多了'
						}
						that.total = res.data.total
						that.dataList = that.dataList.concat(detail)
					} else {
						uni.showToast({
							title: res.data.msg,
							icon: 'none'
						})
					}
				})
			},
	
			switchTabs(flag) {
				this.queryParams.status = flag+''
				this.queryParams.pageNum = 1
				this.dataList = []
				this.getList()
			},


			toDetail(id) {
				uni.navigateTo({
					url: '/pagesMain/production/completedAuditing/detail?id='+id
				})
			},


		},

		onReachBottom: function(e) {
			if (this.total > this.dataList.length) {
				(this.queryParams.pageNum) ++;
				this.getList()
			}
		},
	}
</script>

<style lang="scss" scoped>
	page {
		background: #F9F9F9;
	}

	.main {
		padding: 0;
		padding-bottom: 260upx;
	}
	
	.list {
		padding: 0 24upx;
		width: calc(100% - 48upx);

		.item {
			margin-bottom: 20upx;
			width: calc(100% - 60upx);
			background: #FFFFFF;
			border-radius: 10upx;
			padding: 30upx;
			display: flex;
			justify-content: space-between;


			.item-right {
				width: calc(100%);
				position: relative;

				.item-name {
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #111111;
					border-bottom: 1rpx solid #E4E4E4;
					display: flex;
					justify-content: space-between;
					align-items: center;
					padding-bottom: 12upx;
					margin-bottom: 20upx;
				}
				.item-name-left{
					display: flex;
					align-items: center;
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #111111;
				}
				.item-name-tip{
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #666666;
					margin-left: 10upx;
					margin-right: 20upx;
				}

				.item-single {
					display: flex;
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #666666;
					margin-top: 10upx;
				}

				.item-single-name {
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #666666;
					width: 120rpx;
					display: inline-block;
					margin-right: 12upx;

				}

				.item-single-value {
					display: inline-block;
					width: calc(100% - 120upx - 12upx);
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #111111;
				}




				.item-btn {
					width: 130rpx;
					height: 60rpx;
					background: rgba(17, 170, 102, 0.1);
					border-radius: 30rpx;
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #11AA66;
					text-align: center;
					line-height: 60upx;
				}

				.item-btn-gray {
					background: #EDEDED;
					color: #999999;
				}
			}


		}

	}

	.tabs {
		// margin-top: 26upx;
		width: 100%;
		height: 106upx;
		display: flex;
		align-items: center;
		z-index: 3;
		position: relative;
		background: #FFFFFF;

		.tabs-item {
			height: 106upx;
			line-height: 106upx;
			text-align: center;
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 30rpx;
			color: #999999;
			width: 50%;

		}

		.tabs-item-active {
			font-family: PingFangSC, PingFang SC;
			font-weight: 600;
			font-size: 32rpx;
			color: #11AA66;
			position: relative;
			z-index: 4;
		}

		.tabs-item-text {
			position: relative;
			z-index: 4;
		}

		.tabs-item-active::after {
			content: '';
			position: absolute;
			width: 60rpx;
			height: 8rpx;
			background: linear-gradient(180deg, #11AA66 0%, #12C66B 100%);
			bottom: 0upx;
			left: 50%;
			transform: translateX(-50%);
			z-index: 0;
		}

		.tabs-line {
			width: 2upx;
			height: 40upx;
			background: rgba(228, 228, 228, 1);
		}
	}
</style>